package com.servicesDirectory.action.organisation;


import java.sql.SQLException;
import java.util.List;

import javax.swing.JOptionPane;

import com.opensymphony.xwork2.ActionSupport;
import com.servicesDirectory.common.vo.organisation.OrganisationVO;
import com.servicesDirectory.dao.organisation.OrganisationDAOImpl;


public class OrganisationAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	OrganisationDAOImpl dao = null;
	public List<OrganisationVO> organisations =  null;
	public OrganisationVO organisation;
	private String filter = "";
	private boolean checkInclude;
	protected OrganisationVO org = new OrganisationVO();
    public OrganisationVO getOrg() {
		return org;
	}



    

    public void setOrg(OrganisationVO org) {
		this.org = org;
	}

	@Override

    public String execute() {
    	
        return SUCCESS;
    	
    }
    public String listOrganisation(){
    	//JOptionPane.showMessageDialog(null, "abc");
    	dao = new OrganisationDAOImpl();
        organisations = dao.list(filter, checkInclude);
        return SUCCESS;
    }

    

    
    public String insertOrg() throws ClassNotFoundException, SQLException{
    	OrganisationDAOImpl orgDAO = new OrganisationDAOImpl();        
    	
    	boolean result = orgDAO.insert(org);
    	if(result)
    	{
        return SUCCESS;
    	}
    	else
		return "error";
    }
    @Override
    
    public void validate() {
    }



	public String getFilter() {
		return filter;
	}



	public void setFilter(String filter) {
		this.filter = filter;
	}



	public boolean getCheckInclude() {
		return checkInclude;
	}



	public void setCheckInclude(boolean checkInclude) {
		this.checkInclude = checkInclude;
	}
    
    
}